﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Chenxin.Lib.Hr.BLL
{
    class Hr_Struct_DepartTreeRelation
    {
        #region  成员方法
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation model)
        {
            Chenxin.Lib.Hr.DAL.Hr_Struct_DepartTreeRelation.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation model)
        {
            Chenxin.Lib.Hr.DAL.Hr_Struct_DepartTreeRelation.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(Guid RecordId)
        {

            Chenxin.Lib.Hr.DAL.Hr_Struct_DepartTreeRelation.Delete(RecordId);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation GetModel(Guid RecordId)
        {

            return Chenxin.Lib.Hr.DAL.Hr_Struct_DepartTreeRelation.GetModel(RecordId);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return Chenxin.Lib.Hr.DAL.Hr_Struct_DepartTreeRelation.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation> GetModelList(string strWhere)
        {
            DataSet ds = Chenxin.Lib.Hr.DAL.Hr_Struct_DepartTreeRelation.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation> DataTableToList(DataTable dt)
        {
            List<Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation> modelList = new List<Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Chenxin.Lib.Hr.Entity.Hr_Struct_DepartTreeRelation();
                    if (dt.Rows[n]["RecordId"].ToString() != "")
                    {
                        model.RecordId = new Guid(dt.Rows[n]["RecordId"].ToString());
                    }
                    if (dt.Rows[n]["ParentId"].ToString() != "")
                    {
                        model.ParentId = new Guid(dt.Rows[n]["ParentId"].ToString());
                    }
                    if (dt.Rows[n]["ChildId"].ToString() != "")
                    {
                        model.ChildId = new Guid(dt.Rows[n]["ChildId"].ToString());
                    }
                    if (dt.Rows[n]["ParentName"].ToString() != "")
                    {
                        model.ParentName = dt.Rows[n]["ParentName"].ToString();
                    }
                    if (dt.Rows[n]["ChildName"].ToString() != "")
                    {
                        model.ChildName = dt.Rows[n]["ChildName"].ToString();
                    }
                    if (dt.Rows[n]["ParentProperty"].ToString() != "")
                    {
                        model.ParentProperty = int.Parse(dt.Rows[n]["ParentProperty"].ToString());
                    }
                    if (dt.Rows[n]["ChildProperty"].ToString() != "")
                    {
                        model.ChildProperty =int.Parse(dt.Rows[n]["ChildProperty"].ToString());
                    }
                    if (dt.Rows[n]["ChildCode"].ToString() != "")
                    {
                        model.ChildCode = dt.Rows[n]["ChildCode"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion
    }
}
